$(document).ready(function(){

		function listbox_moveacross(sourceID, destID) 
		{
			var src = document.getElementById(sourceID);
			var dest = document.getElementById(destID);
		 
			for(var count=0; count < src.options.length; count++) 
			{
				if(src.options[count].selected == true) 
				{
					var option = src.options[count];
	 
					var newOption = document.createElement("option");
					newOption.value = option.value;
					newOption.text = option.text;
					newOption.selected = true;
					try {
							 dest.add(newOption, null); //Standard
							 src.remove(count, null);
					 }catch(error) {
							 dest.add(newOption); // IE only
							 src.remove(count);
					 }
					count--;
				}
			}
		}

		$('#leftright').click(function(){
			listbox_moveacross('s', 'd');
			loadingRespCar(1);
		});
		
		$('#rightleft').click(function(){
			listbox_moveacross('d', 's');
			loadingRespCar(1);
		});
		
		$('#leftrightOs').click(function(){
			listbox_moveacross('os', 'osEquipe');
			loadingRespCar(1);
		});
		
		$('#rightleftOs').click(function(){
			listbox_moveacross('osEquipe', 'os');
			loadingRespCar(1);
		});
		
		function loadingRespCar(num)
		{
			var vetEquip = $('#d')[0].options;
			
			if(num==1)
			{
				var valueRespCarro = $('#respCarro')[0].options;
				var tamanho        = valueRespCarro.length;
				
				for(j=(tamanho-1); j <= (valueRespCarro.length-1); j--)
				{
					if(j != -1)
					{
						if(valueRespCarro[j].value != '#')
							valueRespCarro[j].remove();
					}
					else
						break;
				}
			}
			
			for(i=0; i < vetEquip.length; i++)
			{	
				$('#respCarro').append($(vetEquip[i]).clone()[0].outerHTML);
			}
		}
		loadingRespCar();
})